<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<body>
<!--自定义nav块，可以在其他html中调用-->
<div th:fragment="nav">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">社区</span>
                </button>
                <a class="navbar-brand" href="/">社区</a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <form class="navbar-form navbar-left" action="/" method="get">
                    <div class="form-group">
                        <input type="text" class="form-control" name="searchMsg" placeholder="搜索" />
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>



                <ul class="nav navbar-nav navbar-right">

                    <li class="dropdown" th:if="${session.user != null}">
                        <a href="/publish">发帖</a>
                    </li>

                    <li><a href="/profile/notice">通知 <span class="badge" th:text="${session.unReadCount}">11</span></a>
                    </li>


                    <li><a th:href="@{https://gitee.com/oauth/authorize(client_id='58c3f0dbf03cfb5c7e12b14b9c1d7647d8922cc1167b392fcf0df905e642d474',
                    redirect_uri=${#httpServletRequest.getServletContext().getAttribute('redirectUri')},response_type='code')}"
                           th:if="${session.user == null}">登录</a></li>

                   <!-- <li><a href="https://gitee.com/oauth/authorize?client_id=58c3f0dbf03cfb5c7e12b14b9c1d7647d8922cc1167b392fcf0df905e642d474&redirect_uri=http://localhost:8888/login&response_type=code"
                           th:if="${session.user == null}">登录</a></li>-->



                    <li class="dropdown" th:if="${session.user != null}">
                        <a  class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
                            role="button" aria-expanded="false" >
                            <span th:text="${session.user.getName()}">我</span>
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/profile/posts">我的帖子</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="/logout">退出登录</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
</div>

</body>
</html>